package farmer.update.doodad;

import farmer.core.Doodad;

public abstract class Tree extends Doodad{
	
	public static int woodCost = 15;
	public static int rockCost = 0;
	
	protected boolean isReadyToHarvest = true;
	private final int timeToGrow = 10*1000;
	private int timeUntilMature = 0;
	private boolean isSelectedByWorker = false;

	public Tree(int x, int y) {
		super(x, y);
		size = 1;
	}
	
	public void setHarvested(){
		isSelectedByWorker = false;
		isReadyToHarvest = false;
		timeUntilMature = timeToGrow;
	}
	
	public void setWorkerSelect(){
		isSelectedByWorker = true;
	}
	
	public boolean isReadyToHarvest(){
		return isReadyToHarvest && !isSelectedByWorker;
	}
	
	@Override
	public void update(int deltaTime){
		if(timeUntilMature > 0){
			timeUntilMature -= deltaTime;
			if(timeUntilMature <= 0){
				timeUntilMature = 0;
				isReadyToHarvest = true;
			}
		}
	}

}
